<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"                    
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                >


    <ui:define name="content">

        <h:panelGroup id="gpBillPreview" >
            <h:form  >
                <h:panelGrid columns="2">
                    <h:outputLabel value="Select Membership Scheme"/>
                    <p:autoComplete  completeMethod="#{membershipSchemeController.completeMembershipScheme}"
                                     var="pta" itemLabel="#{pta.name}" itemValue="#{pta}" 
                                     forceSelection="true" 
                                     value="#{inwardMemberShipDiscount.currentMembershipScheme}" ></p:autoComplete>
                    <h:outputLabel value="Select Instiution"/>
                    <p:autoComplete  completeMethod="#{institutionController.completeCreditCompany}"
                                     var="pta" itemLabel="#{pta.name}" itemValue="#{pta}" 
                                     forceSelection="true" 
                                     value="#{inwardMemberShipDiscount.institution}" ></p:autoComplete>
                    <h:outputLabel value="Admission Type"/>
                    <p:selectOneMenu    value="#{inwardMemberShipDiscount.admissionType}">        
                        <f:selectItem itemLabel="Select Admission Type"/>
                        <f:selectItems value="#{admissionTypeController.items}" var="i" itemLabel="#{i.name}" itemValue="#{i}"/>  
                        <f:ajax execute="@this" event="change" />
                    </p:selectOneMenu>
                    <h:outputLabel value="Select Paymentmethod"/>
                    <p:selectOneMenu    value="#{inwardMemberShipDiscount.currentPaymentMethod}">        
                        <f:selectItem itemLabel="Select Payment method"/>
                        <f:selectItems value="#{enumController.paymentMethodForAdmission}"/>  
                        <f:ajax execute="@this" event="change" />
                    </p:selectOneMenu>
                    <p:commandButton ajax="false" value="Process" action="#{inwardMemberShipDiscount.createItems()}"/>
                    <p:commandButton ajax="false" value="Clear" action="#{inwardMemberShipDiscount.makeNull()}"/>
                    
                </h:panelGrid>


                <p:dataTable id="discountTable" value="#{inwardMemberShipDiscount.items}" var="prc">
                    <p:column headerText="InwardchargeType">
                        #{prc.inwardChargeType}
                    </p:column>
                    <p:column headerText="Room Category">
                        #{prc.roomCategory.name}
                    </p:column>
                    <p:column headerText="Discount Percent">
                        <p:inputText autocomplete="off" value="#{prc.discountPercent}">
                            <f:ajax event="blur" listener="#{inwardMemberShipDiscount.edit(prc)}"/>
                        </p:inputText>
                    </p:column>
                </p:dataTable>


            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
